export default {
	namespaced: true,
	state: {
		userInfo: uni.getStorageSync('userInfo')|| '',
		productList:[],
		factoryList:[],
		prossType:[],
		printPList:[],
		printItem:{
			factoryObj:[1]
		},
		routers:[
			{
				meta: {
					title: "首页",
					noCache: true,
				},
				name: 'home',
				path:"pages/index/index"
			},{
			meta: {
				title: "订单管理",
				noCache: true,
			},
			name: 'order',
			path:"pages/order/list"
		},
		{
			meta: {
				title: "客户管理",
			},
			name: 'custom',
			path:"pages/custom/index"
		},
		{
			meta: {
				title: "商品管理",
			},
			name: 'product',
			path:"pages/product/index"
		},
		{
			meta: {
				title: "加工方式管理",
			},
			name: 'emus',
			path:"pages/emus/index"
		},
		{
			meta: {
				title: "收入/消费",
			},
			name: 'check',
			path:"pages/check/index"
		}
		// {
		// 	meta: {
		// 		title: "商品管理",
		// 	},
		// 	name: 'brand',
		// },{
		// 	meta: {
		// 		title: "加工方式管理",
		// 	},
		// 	name: 'brand',
		// },{
		// 	meta: {
		// 		title: "对账单",
		// 	},
		// 	name: 'wordFile',
		// },{
		// 	meta: {
		// 		title: "收入/消费",
		// 	},
		// 	name: 'check',
		// },
		],
		curRoute:''
	},
	mutations: {
		setUserInfo(state, value) {
			uni.setStorageSync('userInfo',value)
			state.userInfo = value
		},
		//产品
		setProductList(state,value){
			uni.setStorageSync('productList',value)
			state.productList = value
		},
		//厂商
		setFactoryList(state,value){
			uni.setStorageSync('factoryList',value)
			state.factoryList = value
		},
		// 加工方式
		setProssType(state,value){
			uni.setStorageSync('prossType',value)
			state.prossType = value
		},
		setCurRoute(state,value){
			state.curRoute = value
		},
		setPrintPList(state,value){
			state.printPList = value
		},
		setPrintItem(state,value){
			state.printItem = value
		}
		// setGLType(state,value){
		// 	uni.setStorageSync('gl_type',value)
		// 	state.GLType = value
		// }
		
	},
	actions: {
		init({commit}){
			let product = uniCloud.importObject('xingfu-product')
			let custom = uniCloud.importObject('xingfu-custom')
			let emus = uniCloud.importObject('xingfu-emus')
			
			product.queryAllList().then(res=>{
				commit('setProductList',res.data)
			})
			
			custom.queryAllList().then(res=>{
				res.data.map(item=>{
					item.dictLabel = item.name
					item.dictValue = item._id
				})
				commit('setFactoryList',res.data)
			})
			
			emus.queryListByType('pross_type').then(res=>{
				console.log(res)
				commit('setProssType',res.data)
			})
			
			// emus.queryListByType('gl_type').then(res=>{
			// 	console.log(res)
			// 	commit('setGLType',res.data)
			// })
		},
		
	}
}
